use bindgen::Builder;


const HEAD_PATH: &'static str = "../rtoslib/src4/rtx/rtx_os.h";

fn link_rto4() {
    println!("cargo:rustc-link-search=native=./");
    #[cfg(feature = "cm4")]
    println!("cargo:rustc-link-lib=static=RTOS4");

    #[cfg(feature = "cm3")]
    println!("cargo:rustc-link-lib=static=RTOS3");

    #[cfg(feature = "cm4_25")]
    println!("cargo:rustc-link-lib=static=RTOS4_25MHz");
}

fn convert() {
    let bind = Builder::default()
        .header(HEAD_PATH)
        .use_core()
        .generate().unwrap();
    bind.write_to_file("./rtx_os.rs").unwrap();
}

fn main() {
    link_rto4();
    convert();
}
